package mybatis_learn.mapper;


import mybatis_learn.pojo.Student;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 学生数据Sql映射器
 * @author 老杜
 * @version 1.0
 * @since 1.0
 */
public interface StudentMapper {
    int insert(Student student);
    int insertMap(Map<String, Object> map);
    /*多参数查询，底层会创建map集合，将参数放入map中，map的key为arg0，arg1...0开始或param1.param2...1开始
    * map.put(arg0,name)...
    * map.put(param1,name)....*/
    Long selectCount();
    Student selectByNameSex(@Param("name") String name, @Param("sex") String sex);

    /**
     * 根据name查询
     * @param name
     * @return
     */
    Student selectByName(String name);


    /**
     * 根据id查询
     * @param id
     * @return
     */
    Student selectById(Long id);

    /**
     * 根据birth查询
     * @param birth
     * @return
     */
    Student selectByBirth(Date birth);

    /**
     * 根据sex查询
     * @param sex
     * @return
     */
    Student selectBySex(Character sex);


    List<Student> selectAll();
    //用map存储查询结果
    Map<String, Object> selectByIdMap(Long id);
    //用List<Map>存储查询结果
    List<Map<String, Object>> selectAllMap();
    //大map存储查询结果
    //Map<String(设置为id), Map<String,Object>>;
    @MapKey("id")
    Map<Long, Map<String, Object>> selectAllMap2();

}
